package com.dx;

import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;


public class TankFrame extends Frame {
    int x = 50;
    int y = 50;

    public TankFrame() throws HeadlessException {
        this.setSize(500, 500);
        this.setResizable(false);
        this.setTitle("dx tank war");
        this.setVisible(true);
        this.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });
    }

    @Override
    public void paint(Graphics g) { //窗口重新绘制时自动调用,先清理再调用,跟canvas思路一致
        g.fillRect(x, y, 50, 50);
        x += 50;
        y += 50;
        System.out.println(123);
    }
}